package com.wanxi.education.service.upload.impl;


import com.wanxi.education.service.upload.UploadService;
import com.wanxi.education.util.QiniuCloudUtil;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Author: WangRui
 * @Description:
 * @Date: Created in 2021/9/3 0003
 * @Version: 1.0
 */
@Service
public class UploadServiceImpl implements UploadService {

    @Override
    public String uploadFile(MultipartFile file, String spaceFile) throws Exception {
        byte[] bytes = null;
        System.out.println("fileName=" + file.getOriginalFilename());
        try {
            bytes = file.getBytes();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return QiniuCloudUtil.uploadFileBytes(bytes, file.getOriginalFilename(),spaceFile);
    }

}
